package net.zoneland.knowledge.model;

import java.io.Serializable;
import java.util.Date;
import java.util.Optional;

import com.fasterxml.jackson.annotation.JsonFormat;

import net.zoneland.knowledge.constant.WebConstant;

/**
 * .
 *
 * @author: bcc
 * 2021/5/25
 */
public class ResponseModel<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private String result = WebConstant.RESULT_SUCCESS;

    private String message = WebConstant.SUCCESS;

    private T data;

    private String answerId;

    private Date resTime = new Date();
    /**
     * .
     *
     * @return result
     */
    public String getResult() {
        return result;
    }

    /**
     * .
     *
     * @param result to set
     */
    public void setResult(final String result) {
        this.result = result;
    }

    /**
     * .
     *
     * @return message
     */
    public String getMessage() {
        return message;
    }

    /**
     * .
     *
     * @param message to set
     */
    public void setMessage(final String message) {
        this.message = message;
    }

    /**
     * .
     *
     * @return data
     */
    public T getData() {
        return data;
    }

    /**
     * .
     *
     * @param data to set
     */
    public void setData(final T data) {
        this.data = data;
    }


    /**
     * .
     *
     * @return answerId
     */
    public String getAnswerId() {
        return answerId;
    }

    /**
     * .
     *
     * @param answerId to set
     */
    public void setAnswerId(final String answerId) {
        this.answerId = answerId;
    }

    /**
     * .
     *
     * @return resTime
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Date getResTime() {
        return Optional.ofNullable(resTime).map(it -> (Date) it.clone()).orElse(null);
    }

    /**
     * .
     *
     * @param resTime to set
     */
    public void setResTime(final Date resTime) {
        this.resTime = Optional.ofNullable(resTime).map(it -> (Date) it.clone()).orElse(null);
    }
}
